
/**************** STUDY 3 - KSA (FIGURE 10 IN MANUSCRIPT) ****************/

* Authoritarian Reforms and External Legitimacy, by Calvert W. Jones

* Using Stata/MP 17. Please call up Study3KSA_Data from the appropriate directory.


* Use appropriate directory
import delimited "...\Study3KSA_Data", varnames(1) case(preserve)


* Generate/label DVs

label define favorableLabels 1 "Very unfavorable" 2 "Unfavorable" 3 "Somewhat unfavorable" 4 "Neutral" 5 "Somewhat favorable" 6 "Favorable" 7 "Very favorable"
label values fav_ksa favorableLabels
label values trade_ksa favorableLabels
label values cut_ksa favorableLabels
label values boycott_ksa favorableLabels
label values visit_ksa favorableLabels

* Prepare attributes for analysis

encode nationality_ksa, gen(attribute_nationality_ksa)
encode response_ksa, gen(attribute_response_ksa)
encode critics_ksa, gen(attribute_critics_ksa)
encode reform_ksa, gen(attribute_reform_ksa)
encode experts_ksa, gen(attribute_experts_ksa)

gen anyReform_ksa=.
replace anyReform_ksa=0 if reform_ksa=="control"
replace anyReform_ksa=1 if reform_ksa=="anticorruption" | reform_ksa=="climate change" | reform_ksa=="horizontal" | reform_ksa=="liberal" | reform_ksa=="poverty" | reform_ksa=="proamerican" | reform_ksa=="science" | reform_ksa=="vertical"

label var anyReform_ksa "Reform"
label define anyReform_ksa_values 0 "No reform" 1 "Reform"
label values anyReform_ksa anyReform_ksa_values

/* Re-order attribute levels for some attributes so that they appear in a more natural order within figures, and consistent with first four tasks in Study 3 */ 

* reform_ksa - Make "no reform" the baseline of 1

gen attribute_reform_ksaR = . 
replace attribute_reform_ksaR=1 if attribute_reform_ksa==3 // Control or no reform (was 3)
replace attribute_reform_ksaR=2 if attribute_reform_ksa==5 // Liberal (womens rights, was 5) 
replace attribute_reform_ksaR=3 if attribute_reform_ksa==4 // Horizontal (was 4)
replace attribute_reform_ksaR=4 if attribute_reform_ksa==9 // Vertical (was 9)
replace attribute_reform_ksaR=5 if attribute_reform_ksa==2 // Climate change (was 2)
replace attribute_reform_ksaR=6 if attribute_reform_ksa==8 // Science (was 8)
replace attribute_reform_ksaR=7 if attribute_reform_ksa==6 // Poverty (was 6)
replace attribute_reform_ksaR=8 if attribute_reform_ksa==1 // Anticorruption (was 1)
replace attribute_reform_ksaR=9 if attribute_reform_ksa==7 // Proamerican (was 7)
* To check: browse reform_ksa attribute_reform_ksa attribute_reform_ksaR
/* Now 1=no reform, 2=liberal, 3=horizontal, 4=vertical, 5=climate change, 6=science, 7=poverty; 8=anti-corruption, 9=proamerican */


* Technocratic/experts - make "the ruler" (non-technocratic, or no experts involved) the baseline
gen attribute_experts_ksaR=.
replace attribute_experts_ksaR=1 if attribute_experts_ksa==2
replace attribute_experts_ksaR=2 if attribute_experts_ksa==1
* To check: browse experts_ksa attribute_experts_ksa attribute_experts_ksaR
* Now, 1=the ruler and 2=experts


* Label attributes, including re-ordered ones


* Note this is a variable with reordered attribute levels (R at the end for "reordered")
label var attribute_reform_ksaR "Reform"
label define attribute_reform_ksaR_values 1 "No reform" 2 "Liberal/Diagonal accountability" 3 "Horizontal accountability" 4 "Vertical accountability" 5 "Environment/climate change" 6 "Science and technology" 7 "Global poverty" 8 "Anticorruption" 9 "Pro-American"
label values attribute_reform_ksaR attribute_reform_ksaR_values

label var attribute_critics_ksa "Depth of autocracy"
label define attribute_critics_ksa_values 1 "Autocracy" 2 "Repressive autocracy" 
label values attribute_critics_ksa attribute_critics_ksa_values 

* Note this is a variable with reordered attribute levels (R at the end for "reordered")
label var attribute_experts_ksaR "Technocratic"
label define attribute_experts_ksaR_values 1 "No experts" 2 "Experts involved" 
label values attribute_experts_ksaR  attribute_experts_ksaR_values 

label var attribute_nationality_ksa "Expert nationality"
label define attribute_nationality_ksa_values 1 "American" 2 "Chinese" 3 "International" 4 "Local"
label values attribute_nationality_ksa attribute_nationality_ksa_values 


label var attribute_response_ksa "Observers' response"
label define attribute_response_ksa_values 1 "Neutral" 2 "Skeptical"
label values attribute_response_ksa attribute_response_ksa_values 


 
/* Analysis */
/* Note: To align with the PAP, the two exploratory reforms (labeled as exploratory in the PAP) are excluded from this analysis, though results for them are reported in the appendix. 
*/
 
** Favorability (KSA)

* Using anyReform vs. control (no reform)
regress fav_ksa i.attribute_critics_ksa i.anyReform_ksa if reform_ksa!="anticorruption" & reform_ksa!="proamerican"
estimates store fav_ksa_any_NoExp


* Using all individual reforms vs. control (no reform)
regress fav_ksa i.attribute_critics_ksa i.attribute_reform_ksaR if reform_ksa!="anticorruption" & reform_ksa!="proamerican"
estimates store fav_ksa_all_NoExp

** Trade with country (KSA)

* Using anyReform vs. control (no reform)
regress trade_ksa i.attribute_critics_ksa i.anyReform_ksa if reform_ksa!="anticorruption" & reform_ksa!="proamerican"
estimates store trade_ksa_any_NoExp

* Using all individual reforms vs. control (no reform)
regress trade_ksa i.attribute_critics_ksa i.attribute_reform_ksaR if reform_ksa!="anticorruption" & reform_ksa!="proamerican"
estimates store trade_ksa_all_NoExp

** Cut off relations

* Using anyReform vs. control (no reform)
regress cut_ksa i.attribute_critics_ksa i.anyReform_ksa if reform_ksa!="anticorruption" & reform_ksa!="proamerican"
estimates store cut_ksa_any_NoExp

* Using all individual reforms vs. control (no reform)
regress cut_ksa i.attribute_critics_ksa i.attribute_reform_ksaR if reform_ksa!="anticorruption" & reform_ksa!="proamerican"
estimates store cut_ksa_all_NoExp

** Boycott

* Using anyReform vs. control (no reform)
regress boycott_ksa i.attribute_critics_ksa i.anyReform_ksa if reform_ksa!="anticorruption" & reform_ksa!="proamerican"
estimates store boycott_ksa_any_NoExp

* Using all individual reforms vs. control (no reform)
regress boycott_ksa i.attribute_critics_ksa i.attribute_reform_ksaR if reform_ksa!="anticorruption" & reform_ksa!="proamerican"
estimates store boycott_ksa_all_NoExp

 
* Create Figure 10 in manuscript

coefplot (fav_ksa_any_NoExp, msymbol(O) mcolor(black) label("Favorability") offset(.3)) (trade_ksa_any_NoExp, msymbol(S) mcolor(black) label("Trade with country") offset(.1)) (cut_ksa_any_NoExp, msymbol(T) mcolor(black) label("Cut off relations") offset(-.1)) (boycott_ksa_any_NoExp, msymbol(D) mcolor(black) label("Boycott") offset(-.3)) (fav_ksa_all_NoExp, msymbol(O) mcolor(black) label("Favorability") offset(.3)) (trade_ksa_all_NoExp, msymbol(S) mcolor(black) label("Trade with country") offset(.1)) (cut_ksa_all_NoExp, msymbol(T) mcolor(black) label("Cut off relations") offset(-.1)) (boycott_ksa_all_NoExp, msymbol(D) mcolor(black) label("Boycott") offset(-.3)), keep(*.anyReform_ksa *.attribute_reform_ksaR) headings(0.anyReform_ksa="{bf:Any Reform vs. Control}" 1.attribute_reform_ksaR="{bf:Inward-Facing Reforms vs. Control}" 5.attribute_reform_ksaR="{bf:Outward-Facing Reforms vs. Control}" 8.attribute_reform_ksaR="{bf:Exploratory Reforms vs. Control}") xline(0, lcolor(black))  baselevels drop(_cons) levels(95 90) graphregion(color(white)) bgcolor(white) lcolor(black) ciopts(color(black black)) aspect(3) scale(.6) legend(order(3 6 9 12) col(1) position(3))


* Generate table
esttab fav_ksa_any_NoExp trade_ksa_any_NoExp cut_ksa_any_NoExp boycott_ksa_any_NoExp, label se keep(*.anyReform_ksa)

esttab fav_ksa_all_NoExp trade_ksa_all_NoExp cut_ksa_all_NoExp boycott_ksa_all_NoExp, label se keep(*.attribute_reform_ksaR)